<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE>
<html>
	<head>
		<title>所有用户</title>
		<script type="text/javascript" src="${pageContext.request.contextPath}//jquery.autocomplete/jquery-1.6.2.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/tab.js" charset="utf-8"></script>

		<script type="text/javascript">
			function changPageSize(val) {
				window.location = "${pageContext.request.contextPath}/getAllUsersList.action?pagination.pageSize="+ val;
			}
		</script>
		<style type="text/css">
			.warp_table {
				table-layout: auto;
				font-family: Arial, Helvetica, sans-serif;
				font-size: 15px;
				border: 1px #CCC solid;
				text-align: center;
				border-collapse: collapse;
				width: 950px;
				cursor: default;
			}
			.warp_table th {
				padding: 5px;
				color: #03C;
				padding: .6em;
			}
			.warp_table tbody tr.select {
				background: #EFe
			}
			.warp_table tbody tr.select td {
				color: #900;
				border-bottom-color: #0CC
			}
			.warp_table tbody tr.over {
				background: #EFF
			}
			.warp_table tbody tr.over td {
				color: #03c
			}
			.warp_table td {
				border-bottom: 1px #ccc solid;
				border-top: 1px #ccc solid;
				padding: .2em;
				color: #000;
			}
			.warp_table td.highlight {
				color: #03c
			}
			.warp_table span {
				padding: .2em
			}
			.warp_table colgroup col {
				background-image: none; /*IE下的colgroup会继承table的背景设置 所以这里设置none*/
			}
			.warp_table colgroup col.c2 {
				text-align: right;
			}
			.warp_table td+td+td+td+td+td+td+td+td {
				text-align: right;
			}
			.warp_table td:last-child {
				text-align: center
			}/*发现IE7并不支持last:child  倒是支持first:child*/
			.warp_table input {
				cursor: pointer
			}
		</style>
	</head>

	<body>
	<form action="${pageContext.request.contextPath}/getAllUsersList.action" method="post">
		<center>
			查询(用户名)：<input type="text" name="users.userName" id="userName" value="${users.userName}">&nbsp;&nbsp;<input type="submit" value="查  询">
			<span style="font-size: 12px; color: red;">（空查询所有）</span>
		</center>
	</form>
		<table class="warp_table" align="center">
			<caption>
				<h2>用户列表</h2>
			</caption>
			<colgroup>
				<col class="cc" />
				<col />
				<col />
				<col />
				<col />
				<col />
				<col />
				<col />
				<col class="c2" />
				<col class="c2" />
				<col />
			</colgroup>
			<thead>
				<tr>
					<th>序号</th>
					<th>用户名</th>
					<th>密码</th>
				</tr>
			</thead>
			<tbody>
				<c:if test="${pagination.items== null || fn:length(pagination.items) == 0}">
					<tr>
						<td colspan="4">
							<span style="color: #03C;"><strong>抱歉！没有与"<span style="color: red;">${users.userName }</span>"开头的用户！</strong></span>
						</td>
					</tr>
				</c:if>
				<c:if test="${pagination.items!= null || fn:length(pagination.items) != 0}">
					<c:forEach var="user" varStatus="i" items="${pagination.items }">
						<tr>
							<td>${i.index+1}</td>
							<td>${user.userName }</td>
							<td>${fn:substring(user.passWord,0,1)}*****</td>
						</tr>
					</c:forEach>
				</c:if>
			</tbody>
			<tr>
				<td colspan="4">总记录<strong style="color: #03C;">${pagination.totalCount }</strong>条
					<c:if test="${pagination.currentPage != 1}">
						<a href="${pageContext.request.contextPath}/getAllUsersList.action?pagination.startIndex=0">首页</a>
						<a href="${pageContext.request.contextPath}/getAllUsersList.action?pagination.startIndex=${pagination.previousIndex }">上一页</a>
					</c:if>
					<c:if test="${pagination.pages != 1 }">
						<c:forEach var="i" items="${page}">
							<c:choose>
								<c:when test="${i==-1}">...</c:when>
								<c:when test="${i==pagination.currentPage}">
									<strong><a href="${pageContext.request.contextPath}/getAllUsersList.action?page=${i}" style="color: red;">${i}</a></strong>
								</c:when>
								<c:otherwise>
									<a href="${pageContext.request.contextPath}/getAllUsersList.action?page=${i}">${i}</a>
								</c:otherwise>
							</c:choose>
						</c:forEach>
						<c:if test="${requestScope.pagination.currentPage != pagination.pages}">
							<a href="${pageContext.request.contextPath}/getAllUsersList.action?pagination.startIndex=${pagination.nextIndex }">下一页</a>
							<a href="${pageContext.request.contextPath}/getAllUsersList.action?pagination.startIndex=${pagination.laststartIndex }">尾页</a>
						</c:if>
					</c:if>
					共有<strong style="color: #03C;">${pagination.pages }</strong>页，当前是第<strong style="color: red;">${requestScope.pagination.currentPage}</strong>页，每页显示
					<select name="pagination.pageSize" onchange="changPageSize(this.value);">
						<c:forEach var="i" begin="10" step="10" end="100">
							<c:if test="${pagination.pageSize==i }">
								<option value="${i }" selected="selected"> ${i }</option>
							</c:if>
							<c:if test="${pagination.pageSize!=i }">
								<option value="${i }">${i }</option>
							</c:if>
						</c:forEach>
					</select>
					条
				</td>
			</tr>
		</table>
	</body>
</html>
